const Sequelize = require('sequelize')
const sequelize = require('../config/index')
let Company = sequelize.define('company',{
    id:{
        type:Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        comment:'企业id',
    },
    uid:{
        type:Sequelize.STRING,
        defaultValue:'',
        comment:'用户id',
    },
    name:{
        type:Sequelize.INTEGER,
        defaultValue:0,
        comment:'企业名称',
    },
    avatar:{
        type:Sequelize.STRING,
        defaultValue:'无',
        comment:'企业头像'
    },
    description:{
        type:Sequelize.STRING,
        defaultValue:'无',
        comment:'description',
    },
    certification:{
        type:Sequelize.INTEGER,
        defaultValue:'0',
        comment:'企业认证',
    },
    address:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'企业地址',
    },
   phone:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'企业电话'
    },
    banned:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'是否封禁'
    },
    vip:{
        type:Sequelize.STRING,
        defaultValue:0,
        comment:'是否vip'
    },
    ali_account:{
        type:Sequelize.STRING,
        defaultValue:null,
        comment:'支付宝账户'
    },
   wechat_account:{
        type:Sequelize.STRING,
        defaultValue:null,
        comment:'微信账户'
    },
},{
    // freezeTabelName 为 true 时不会在库中映射表时增加复数表名
    // 该选项为 true 时，user 在映射时映射成 user，而为 false 时会映射成users
    freezeTableName: true,
})
//Company.belongsTo(User,{foreignKey: "uid"});
// Skill.belongsToMany(User, {through : 'userSkill'});
//这会创建一个新模型UserProject,其中projectId和userId两个外键。定义through选项后，Sequelize会尝试自动生成名字。
//在本例中，会为User添加方法getUsers,setUsers,addUser,addUsers到Project中。getProjects,setProjects,addProject,addProjects到User中.


let company = Company.sync();

module.exports = Company

